<HTML><HEAD><TITLE>insetdomain(?Set, ?CardSel, ?ElemSel, ?Order)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">library(ic_hybrid_sets)</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>insetdomain(?Set, ?CardSel, ?ElemSel, ?Order)</H1>
Instantiate Set to a possible value
<DL>
<DT><EM>Set</EM></DT>
<DD>a set or set variable
</DD>
<DT><EM>CardSel</EM></DT>
<DD>atom or variable
</DD>
<DT><EM>ElemSel</EM></DT>
<DD>atom, structure or variable
</DD>
<DT><EM>Order</EM></DT>
<DD>atom or variable
</DD>
</DL>
<H2>Description</H2>
<P>
    This predicate instantiates a set variable to a possible value,
    according to its domain.  The predicate backtracks over all
    possible set instantiations.  The three option arguments allow to
    choose between a number of different enumeration orders. Giving a
    variable as option argument will select the default.
</P><P>
    The <B>CardSel</B> argument determines whether the sets are enumerated
    according to their cardinality. It can take the following values:
<DL>
<DT><B>any</B> (default)</DT>
    <DD>the sets are not enumerated in a particular cardinality order</DD>
<DT><B>increasing</B></DT>
    <DD>the sets are enumerated with increasing cardinality, ie. small
    sets are tried first</DD>
<DT><B>decreasing</B></DT>
    <DD>the sets are enumerated with decreasing cardinality, ie. large
    sets are tried first</DD>
</DL>
</P><P>
    The <B>ElemSel</B> argument determines which potential set elements
    are considered first for inclusion or exclusion. It can take the
    following values:
<DL>
<DT><B>small_first</B> (default)</DT>
    <DD>small set elements (small numbers) are considered first</DD>
<DT><B>big_first</B></DT>
    <DD>big set elements (big numbers) are considered first</DD>
<DT><B>random</B></DT>
    <DD>potential set elements are considered in random order</DD>
<DT><B>heavy_first(Weights)</B></DT>
    <DD>heavy set elements (according to Weight array) are considered first</DD>
<DT><B>light_first(Weights)</B></DT>
    <DD>light set elements (according to Weight array) are considered first</DD>
</DL>
</P><P>
    The <B>Order</B> argument determines whether it is first tried to make
    the selected potential element a set member, or whether to exclude it
    first.  The argument can take the following values:
<DL>
<DT><B>in_notin</B> (default)</DT>
    <DD>try inclusion first, then exclusion</DD>
<DT><B>notin_in</B></DT>
    <DD>try exclusion first, then inclusion</DD>
<DT><B>sbds</B></DT>
    <DD>uses sbds_try/2 to include or exclude an element in or from a set
    (this is for use in conjunction with the SBDS library, and whether
    inclusion or exclusion is tried first depends on the "fix pred"
    specified in the prior call to sbds_initialise/4 or sbds_initialise/5)</DD>
</DL>
</P><P>
    Note that there are many different enumeration strategies for a set
    variable, and insetdomain/4 only allows a limited number of them.
    For an actual application, it might be more appropriate to choose a
    problem-specific enumeration order. This can be programmed easily.
    As a guideline, here is the code for insetdomain with the default
    options:
<PRE>
    insetdomain(Set, _, _, _) :-
    	nonvar(Set).
    insetdomain(Set, any, small_first, in_notin) :-
    	var(Set),
    	potential_members(Set, PotentialElements),
	PotentialElements = [Element|_],
	(
	    Element in Set
	;
	    Element notin Set
	),
	insetdomain(Set, any, small_first, in_notin).
</PRE>

<H3>Resatisfiable</H3>
yes
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>Set is a variable, but not a set variable
</DL>
<H2>Examples</H2>
<PRE>
?-  X::[]..[1,2,3], insetdomain(X,_,_,_), writeln(X), fail.
[1, 2, 3]
[1, 2]
[1, 3]
[1]
[2, 3]
[2]
[3]
[]

no (more) solution.
?-  X::[]..[1,2,3], insetdomain(X,increasing,_,_), writeln(X), fail.
[]
[1]
[2]
[3]
[1, 2]
[1, 3]
[2, 3]
[1, 2, 3]

no (more) solution.
?-  X::[]..[1,2,3], insetdomain(X,_,big_first,_), writeln(X), fail.
[1, 2, 3]
[2, 3]
[1, 3]
[3]
[1, 2]
[2]
[1]
[]

no (more) solution.
?-  X::[]..[1,2,3], insetdomain(X,_,_,notin_in), writeln(X), fail.
[]
[3]
[2]
[2, 3]
[1]
[1, 3]
[1, 2]
[1, 2, 3]

no (more) solution.
?-  X::[]..[1,2,3],
	insetdomain(X, increasing, heavy_first([](2,9,4,7)), _),
	writeln(X), fail.
[]
[2]
[3]
[1]
[2, 3]
[1, 2]
[1, 3]
[1, 2, 3]

no (more) solution.
</PRE>
<H2>See Also</H2>
<A HREF="../../lib/conjunto/refine-1.html">conjunto : refine / 1</A>, <A HREF="../../lib/conjunto_fd_sets/refine-1.html">conjunto_fd_sets : refine / 1</A>, <A HREF="../../lib/ic_hybrid_sets/potential_members-2.html">potential_members / 2</A>, <A HREF="../../lib/ic_gap_sbds/sbds_try-2.html">ic_gap_sbds : sbds_try / 2</A>, <A HREF="../../lib/ic_sbds/sbds_try-2.html">ic_sbds : sbds_try / 2</A>, <A HREF="../../lib/fd_sbds/sbds_try-2.html">fd_sbds : sbds_try / 2</A>, <A HREF="../../lib/ic_sbds/sbds_initialise-4.html">ic_sbds : sbds_initialise / 4</A>, <A HREF="../../lib/fd_sbds/sbds_initialise-4.html">fd_sbds : sbds_initialise / 4</A>, <A HREF="../../lib/ic_gap_sbds/sbds_initialise-5.html">ic_gap_sbds : sbds_initialise / 5</A>, <A HREF="../../lib/ic_sbds/sbds_initialise-5.html">ic_sbds : sbds_initialise / 5</A>, <A HREF="../../lib/fd_sbds/sbds_initialise-5.html">fd_sbds : sbds_initialise / 5</A>
</BODY></HTML>
